home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asmbler.arc / CALL.ASM < prev    next >
Assembly Source File  |  1988-11-19  |  3KB  |  100 lines

  1. NULLSTR EQU     0
  2.  
  3. PUBLIC  SYSTEM
  4. EXTRN   CESXQQ:WORD
  5. ASSUME  CS:SYSTEMC
  6. SYSTEMC SEGMENT PARA PUBLIC 'CODE'
  7.  
  8. EXECDEF STRUC
  9. NENVIRO DW
  10. COMMND  DW      2 DUP (0)
  11. FCB5CH  DW      2 DUP (0)
  12. FCB6CH  DW      2 DUP (0)
  13. EXECDEF ENDS
  14.  
  15. EXECBLK EXECDEF <>
  16. SPSAVE  DW
  17. SSSAVE  DW
  18.  
  19. EXECOMM PROC    NEAR
  20.         ; Here we actually execute the command.  
  21.         PUSH    AX
  22.         PUSH    BX
  23.         PUSH    CX
  24.         PUSH    DX
  25.         PUSH    SI
  26.         PUSH    DI
  27.         PUSH    BP
  28.         PUSH    DS
  29.         PUSH    ES
  30.         MOV     CS:SPSAVE,SP
  31.         MOV     CS:SSSAVE,SS
  32.         MOV     CS:EXECBLK.NENVIRO,0            ; Same environment as us.
  33.         MOV     CS:EXECBLK.COMMND[0],0          ; Set the command line here
  34.         MOV     CS:EXECBLK.COMMND[2],0
  35.         MOV     CS:EXECBLK.FCB5CH[0],0
  36.         MOV     CS:EXECBLK.FCB5CH[2],0
  37.         MOV     CS:EXECBLK.FCB6CH[0],0
  38.         MOV     CS:EXECBLK.FCB6CH[2],0
  39.         MOV     AX,CS
  40.         MOV     ES,AX
  41.         MOV     BX,OFFSET EXECBLK
  42.         MOV     AH,4BH
  43.         MOV     AL,0
  44.         INT     21H
  45.         MOV     SS,CS:SSSAVE
  46.         MOV     SP,CS:SPSAVE
  47.         POP     ES
  48.         POP     DS
  49.         POP     BP
  50.         POP     DI
  51.         POP     SI
  52.         POP     DX
  53.         POP     CX
  54.         POP     BX
  55.         POP     AX
  56.         RET
  57. EXECOMM ENDP
  58.  
  59. SYSTEM  PROC    FAR
  60.         ; function call(var s: lstring): integer; external;
  61.         PUSH    BP
  62.         MOV     BP,SP
  63.         ; This will free up the segment above the current data segment.
  64.         ; This is for the Pascal 1.0 model which puts stack, data, and
  65.         ; heap together in a segment above all the code spaces.  If you
  66.         ; need to save some of the higher memory then this is where to
  67.         ; fix this package.  Of course the best way is to do this is to
  68.         ; make SHRINKSPACE a procedure callable from your program and
  69.         ; pass in a segmented address of the first available memory.
  70.         MOV     ES,CESXQQ
  71.         MOV     BX,DS
  72.         ADD     BX,4096         ; 65536 / 16
  73.         MOV     AH,4AH
  74.         INT     21H
  75.         JC      ERR1
  76.         IF      NULLSTR
  77.         MOV     DX,[BP+6]
  78.         ELSE
  79.         ; If it is a Pascal lstring then nul terminate it for DOS.
  80.         MOV     BX,[BP+6]
  81.         MOV     DL,[BX]
  82.         XOR     DH,DH
  83.         ADD     BX,DX
  84.         MOV     BYTE PTR [BX+1],0
  85.         MOV     DX,[BP+6]
  86.         INC     DX
  87.         ENDIF
  88.         ;        execute command.com with the line as the parameter
  89.         CALL    EXECOMM
  90.         JC      ERR1
  91.         MOV     AH,4DH          ; Any error code returned?
  92.         INT     21H
  93. ERR1:   MOV     SP,BP
  94.         POP     BP
  95.         RET     2
  96. SYSTEM  ENDP
  97.  
  98. SYSTEMC ENDS
  99.         END
  100.